Non-volatile memory systems, such as flash memory, have been widely adopted for use in consumer products. Flash memory may be found in different forms, for example in the form of a portable memory card that can be carried between host devices or as a solid state disk (SSD) embedded in a host device. As the non-volatile memory cell scales to smaller dimensions with higher capacity per unit area, the cell endurance due to program and erase cycling, and disturbances (e.g. due to either read or program operation) may become more prominent.
A host of a memory card typically uses a file system, for example a file system such as FAT32, exFAT, ext2,3 or other known host file systems, to address files and store information about files. The memory card is unaware of this file system and how it is used by the host. NAND flash memory has several known operating restrictions. For example, NAND flash may be written to in increments of a physical page and may be erased in increments of blocks, where each block is a collection of multiple pages. Data may be overwritten in the same block only after erase. For this reason, whenever a logical address location which is only part of a block, the firmware does not move the entire physical block to a new block with the overwritten data. Instead, it just marks the stale data as invalid and writes the overwritten data to a new block. After the entire card capacity is full, the memory card performs compaction. During the process of compaction, the memory card picks previously programmed source blocks with invalid data and, for each block, copies the valid data from the picked source blocks to a new block and then erases and re-uses the source block. During this process, it is possible that firmware may pick up logical addresses associated with deleted files (deleted in the host file system directory, but not yet deleted/overwritten in the logical-to-physical mapping table in the memory card) that are still valid according to the firmware, but have not yet been overwritten with new data. Such logical addresses are destined to be over-written very soon as they are actually associated with stale host data. When a write command directed to these logical addresses comes from the host, the data associated with those logical addresses and that has just been moved into the destination block will have to be invalidated by the firmware. This then may lead to unnecessary compaction of this destination block again.